<?php
	// Make sure we're logged in (send us to the front page if not)
	gatekeeper();
  // Make sure action is secure
  //action_gatekeeper();
	
  $q=get_input('q');
	
  if(empty($q))
  {
    echo '[]';
  }
  else{
    $list=search_for_user($q);
    $li="[";
    $i=1;
    foreach($list as $l){
      if ($i>=count($list) && ($l->role!='student')){
        $li.="{name:'".$l->name." (".$l->username.")', id:'".$l->guid."'}";
      }                        
      elseif($i<count($list) && $l->role!='student'){
        $li.="{name:'".$l->name." (".$l->username.")', id:'".$l->guid."'},";
      }
      $i=$i+1;
    }
    $li.="]";
    echo $li;
  }
?>
